package com.example.yichuangyun.ui.activity.business;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;

import androidx.core.content.res.ResourcesCompat;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.yichuangyun.R;
import com.example.yichuangyun.config.Constant;
import com.example.yichuangyun.databinding.ActivityNewBusinessDetailsBinding;
import com.example.yichuangyun.dialog.EditDialog;
import com.example.yichuangyun.dialog.ExamineDialog;
import com.example.yichuangyun.dialog.MyDialog;
import com.example.yichuangyun.dialog.SinglePickerView;
import com.example.yichuangyun.http.HttpRespond;
import com.example.yichuangyun.http.MyObserver;
import com.example.yichuangyun.http.RetrofitHelper;
import com.example.yichuangyun.model.EventBusModel;
import com.example.yichuangyun.model.business.BusinessDetailsModel;
import com.example.yichuangyun.model.business.BusinessModel;
import com.example.yichuangyun.model.business.ProductModel;
import com.example.yichuangyun.model.call.TabModel;
import com.example.yichuangyun.model.contacts.ContactPersonModel;
import com.example.yichuangyun.model.contacts.ContactWayModel;
import com.example.yichuangyun.mvvm.base.BaseActivity;
import com.example.yichuangyun.mvvm.base.BaseViewModel;
import com.example.yichuangyun.mvvm.ui.activity.CompanyDetailsActivity;
import com.example.yichuangyun.mvvm.ui.activity.order.PlaceOrderActivity;
import com.example.yichuangyun.ui.activity.follow.AddFollowActivity;
import com.example.yichuangyun.ui.adapter.ViewPagerAdapter;
import com.example.yichuangyun.ui.fragment.DetailsCallRecordFragment;
import com.example.yichuangyun.ui.fragment.DetailsDataFragment;
import com.example.yichuangyun.ui.fragment.DetailsFollowRecordFragment;
import com.example.yichuangyun.ui.fragment.DetailsOrderRecordFragment;
import com.example.yichuangyun.utils.CommonUtil;
import com.example.yichuangyun.utils.JumpIntent;
import com.example.yichuangyun.utils.RequestUtils;
import com.example.yichuangyun.utils.ToastHelper;
import com.example.yichuangyun.utils.UMengUtil;
import com.example.yichuangyun.utils.UiUtils;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.google.gson.Gson;
import com.google.gson.JsonArray;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * 商机详情
 */
public class BusinessDetailsActivity extends BaseActivity<ActivityNewBusinessDetailsBinding, BaseViewModel> implements View.OnClickListener {

    private int businessType;
    private String businessId, businessCode, creditNo;
    private int businessStepStatus;
    private String createUserId, followUserId;
    private final ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
    private final List<Fragment> fragments = new ArrayList<>();
    private String[] titles;
    private final List<String> progressTitle = new ArrayList<>();
    private final Set<Integer> set = new HashSet<>();
    private final List<String> titleData = new ArrayList<>();
    private BusinessDetailsModel detailsModel;
    private String clientName, mTelNumber;
    private final List<String> tels = new ArrayList<>();
    private boolean isRefresh, isOpen;
    private MyDialog myDialog;

    @Override
    protected BaseViewModel bindModel() {
        return getViewModel(this, BaseViewModel.class);
    }

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    public void initData() {
        initTitleBar(getString(R.string.info_details));
        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            businessType = bundle.getInt(Constant.businessTypeKey);
            BusinessModel model = bundle.getParcelable(Constant.modelKey);
            if (model != null) {
                businessId = model.getId();
                businessCode = model.getSjCode();
                creditNo = model.getCreditNo();
                businessStepStatus = model.getStepStatus();
                createUserId = model.getCreateUserId();
                followUserId = model.getGdUserId();
                int oldUser = model.getOldUser();
                binding.tvOldCustomer.setVisibility(oldUser == 1 ? View.VISIBLE : View.GONE);
                if (model.getDiscardStatus() == 0) {
                    if (businessStepStatus != 60 && businessStepStatus != 70 && businessStepStatus != 80
                            && !model.getGdUser().equals(getString(R.string.gh)) && !model.getGdUser().equals(getString(R.string.business_pool))
                            && model.getIsOrder() != 1 && businessType != 4 && businessType != 5) {
                        if (businessType == 0 || businessType == 1) { // 我创建的/部门创建的页面，创建人和跟进人不是同一个人的话，创建人不能生成订单，丢单或者废弃的
                            if (model.getCreateUserId().equals(model.getGdUserId())) {
                                titleData.add(getString(R.string.create_order));
                            }
                        } else {
                            titleData.add(getString(R.string.create_order));
                        }
                    }
                    // businessStepStatus：10新入库 20需跟踪 30确认意向 40邀约成功 50面谈成功 60签约成功 70丢单 80废弃 90未签约
                    // 新入库、需跟踪、确认意向、邀约成功、面谈成功、未签约 --> 拨打电话、跟进、编辑、废弃/丢单（老客户的商机才可以废弃），设置共享人；
                    if (businessStepStatus == 10 || businessStepStatus == 20 || businessStepStatus == 30
                            || businessStepStatus == 40 || businessStepStatus == 50 || businessStepStatus == 90) {
                        titleData.add(getString(R.string.set_share_person));
                    } else if (businessStepStatus == 60 || businessStepStatus == 80) { // 签约成功或废弃的只能拨打电话
                        binding.tvFollowText.setTextColor(0xFF7C7C7C);
                        binding.tvEditText.setTextColor(0xFF7C7C7C);
                        binding.tvMoreText.setTextColor(0xFF7C7C7C);
                        binding.llAddFollow.setEnabled(false);
                        binding.llEdit.setEnabled(false);
                        binding.llMore.setEnabled(false);
                    } else if (businessStepStatus == 70) {
                        binding.tvMoreText.setTextColor(0xFF7C7C7C);
                        binding.llMore.setEnabled(false);
                    }
                    // 共享给我的，共享给部门的， 都不能生成订单，以及丢单和废弃
                    if (businessStepStatus != 60 && businessStepStatus != 70 && businessStepStatus != 80
                            && !model.getGdUser().equals(getString(R.string.gh)) && !model.getGdUser().equals(getString(R.string.business_pool))
                            && businessType != 4 && businessType != 5) {
                        if (businessType == 0 || businessType == 1) { // 我创建的/部门创建的页面，创建人和跟进人不是同一个人的话，创建人不能生成订单，丢单或者废弃的
                            if (model.getCreateUserId().equals(model.getGdUserId())) {
                                titleData.add(model.getOldUser() == 1 ? context.getString(R.string.discard) : context.getString(R.string.lost_order));
                            }
                        } else {
                            titleData.add(model.getOldUser() == 1 ? context.getString(R.string.discard) : context.getString(R.string.lost_order));
                        }
                    }
                } else if (model.getDiscardStatus() == 1) {
                    if (businessType == 0 || businessType == 1) {
                        titleData.add(getString(R.string.discard_examine));
                    } else {
                        binding.tvMoreText.setTextColor(0xFF7C7C7C);
                        binding.llMore.setEnabled(false);
                    }
                    binding.tvFollowText.setTextColor(0xFF7C7C7C);
                    binding.tvEditText.setTextColor(0xFF7C7C7C);
                    binding.llAddFollow.setEnabled(false);
                    binding.llEdit.setEnabled(false);
                } else {
                    binding.tvFollowText.setTextColor(0xFF7C7C7C);
                    binding.tvEditText.setTextColor(0xFF7C7C7C);
                    binding.tvMoreText.setTextColor(0xFF7C7C7C);
                    binding.llAddFollow.setEnabled(false);
                    binding.llEdit.setEnabled(false);
                    binding.llMore.setEnabled(false);
                }
            }
        }

        titles = new String[]{getString(R.string.follow_record), getString(R.string.call_record), getString(R.string.order_record), getString(R.string.info_details)};
        for (String title : titles) {
            mTabEntities.add(new TabModel(title));
        }

        progressTitle.add(getString(R.string.new_storage));
        progressTitle.add(getString(R.string.to_be_tracked));
        progressTitle.add(getString(R.string.confirm_intent));
        progressTitle.add(getString(R.string.invitation));
        progressTitle.add(getString(R.string.interview));
        progressTitle.add(getString(R.string.sign_contract));

        int progressSize = progressTitle.indexOf(UiUtils.getProgressState(businessStepStatus));
        for (int i = 0; i <= progressSize; i++) {
            set.add(i);
        }
        binding.progressBar.setNodeData(progressTitle, set);
        initDialog();
        showLoadingDialog();
        getBusinessDetails();
    }

    /**
     * 商机详情
     */
    private void getBusinessDetails() {
        RetrofitHelper.getInstance().execute(RetrofitHelper.getService().getBusinessDetails(businessId), new MyObserver<HttpRespond<BusinessDetailsModel>>() {
                    @SuppressLint("SetTextI18n")
                    @Override
                    protected void onSuccess(HttpRespond<BusinessDetailsModel> businessDetailsModelHttpRespond) {
                        if (Constant.SUCCESS == businessDetailsModelHttpRespond.code) {
                            detailsModel = businessDetailsModelHttpRespond.data;
                            if (null != detailsModel) {
                                tels.clear();
                                List<ContactPersonModel> telsList = detailsModel.getAppTels();
                                if (null != telsList && telsList.size() > 0) {
                                    for (ContactPersonModel contactPersonModel : telsList) {
                                        for (ContactWayModel contactWayModel : contactPersonModel.getTels()) {
                                            if (contactWayModel.getType() == 1) {
                                                tels.add(contactWayModel.getInfo());
                                            }
                                        }
                                    }
                                }
                                businessStepStatus = detailsModel.getStepStatus();
                                mTelNumber = detailsModel.getTelNumber();
                                clientName = detailsModel.getUserName();
                                binding.tvContactName.setText(CommonUtil.checkText(detailsModel.getUserName()));
                                binding.tvContactNum.setText(CommonUtil.checkText(detailsModel.getTelNumber()));
                                binding.tvCompanyName.setText(CommonUtil.setText(detailsModel.getCompName()));
                                binding.tvNextFollowTime.setText(CommonUtil.setYHMTime(detailsModel.getNextFollowTime()));
                                StringBuilder builder = new StringBuilder();
                                if (detailsModel.getProductList() != null && detailsModel.getProductList().size() > 0) {
                                    // 只有一条意向产品并且超过一行，换行展示全称
                                    binding.tvMore.setVisibility(detailsModel.getProductList().size() > 1 ? View.VISIBLE : View.GONE);
                                    if (detailsModel.getProductList().size() > 1) {
                                        binding.tvMore.setVisibility(View.VISIBLE);
                                        Drawable drawable;
                                        if (isOpen) {
                                            binding.tvProductName.setMaxLines(Integer.MAX_VALUE);
                                            binding.tvMore.setText(getString(R.string.no_expand));
                                            drawable = ResourcesCompat.getDrawable(getResources(), R.mipmap.icon_up_blue, null);
                                        } else {
                                            binding.tvProductName.setMaxLines(1);
                                            binding.tvMore.setText(getString(R.string.more));
                                            drawable = ResourcesCompat.getDrawable(getResources(), R.mipmap.icon_down_blue, null);
                                        }
                                        binding.tvMore.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
                                    } else {
                                        binding.tvProductName.setMaxLines(1);
                                        binding.tvMore.setVisibility(View.GONE);
                                        binding.tvMore.setText(getString(R.string.no_expand));
                                    }

                                    for (int i = 0; i < detailsModel.getProductList().size(); i++) {
                                        ProductModel productModel = detailsModel.getProductList().get(i);
                                        String pName = TextUtils.isEmpty(productModel.getProductFullName()) ? productModel.getProductName() : productModel.getProductFullName();
                                        if (i == 0) {
                                            builder.append(pName).append(detailsModel.getProductList().size() > 1 ? "\n" : "");
                                        } else if (i == detailsModel.getProductList().size() - 1) {
                                            builder.append(pName);
                                        } else {
                                            builder.append(pName).append("\n");
                                        }
                                    }
                                    binding.tvProductName.setText(builder.toString());
                                }

                                binding.tvMore.setOnClickListener(view -> {
                                    Drawable drawable;
                                    isOpen = !isOpen;
                                    if (isOpen) {
                                        binding.tvProductName.setMaxLines(Integer.MAX_VALUE);
                                        binding.tvMore.setText(getString(R.string.no_expand));
                                        drawable = ResourcesCompat.getDrawable(getResources(), R.mipmap.icon_up_blue, null);
                                    } else {
                                        binding.tvProductName.setMaxLines(1);
                                        binding.tvMore.setText(getString(R.string.more));
                                        drawable = ResourcesCompat.getDrawable(getResources(), R.mipmap.icon_down_blue, null);
                                    }
                                    binding.tvMore.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
                                });
                                if (!isRefresh) {
                                    initFragment();
                                }
                                binding.smartRefreshLayout.finishRefresh();
                            }
                        }
                        dismissLoadingDialog();
                    }

                    @Override
                    protected void onFail(Throwable e) {
                        super.onFail(e);
                        dismissLoadingDialog();
                    }
                }
        );
    }

    private void initFragment() {
        fragments.add(DetailsFollowRecordFragment.newInstance(businessId, businessCode));
        fragments.add(DetailsCallRecordFragment.newInstance(businessId, businessCode, clientName));
        fragments.add(DetailsOrderRecordFragment.newInstance(businessId));
        fragments.add(DetailsDataFragment.newInstance(businessId, clientName));
        binding.viewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), 0, titles, fragments));
        binding.tabLayout.setTabData(mTabEntities);
    }

    @Override
    protected void initClick() {
        binding.tvContactNum.setOnClickListener(this);
        binding.llCall.setOnClickListener(this);
        binding.llAddFollow.setOnClickListener(this);
        binding.llEdit.setOnClickListener(this);
        binding.llMore.setOnClickListener(this);
        binding.smartRefreshLayout.setOnRefreshListener(refreshLayout -> {
            isRefresh = true;
            getBusinessDetails();
        });

        binding.tvCompanyName.setOnClickListener(view -> {
            if (CommonUtil.isCanClick()) {
                Bundle bundle = new Bundle();
                bundle.putString(Constant.creditNoKey, creditNo);
                JumpIntent.jump(this, CompanyDetailsActivity.class, bundle);
            }
        });
        binding.viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                binding.tabLayout.setCurrentTab(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        binding.tabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                binding.viewPager.setCurrentItem(position);
            }

            @Override
            public void onTabReselect(int position) {
            }
        });
    }

    @Override
    public void onClick(View view) {
        if (!CommonUtil.isCanClick()) {
            return;
        }
        int id = view.getId();
        if (id == R.id.tv_contact_num || id == R.id.ll_call) {
            UMengUtil.setCountEventId(Constant.DETAILS_CALL);
            if (tels.size() == 1) {
                RequestUtils.checkCallNum(context, mTelNumber, myDialog, 0, true);
            } else {
                initSinglePickerView(tels, getString(R.string.call_num));
            }
        } else if (id == R.id.ll_add_follow) {
            UMengUtil.setCountEventId(Constant.DETAILS_ADD_FOLLOW);
            Bundle bundle = new Bundle();
            bundle.putInt(Constant.flagKey, 0);
            bundle.putString(Constant.businessIdKey, businessId);
            bundle.putString(Constant.nameKey, clientName);
            bundle.putStringArrayList(Constant.telKey, (ArrayList<String>) tels);
            JumpIntent.jump((Activity) context, AddFollowActivity.class, bundle);
        } else if (id == R.id.ll_edit) {
            checkButtonOrTab(5);
        } else if (id == R.id.ll_more) {
            initSinglePickerView(titleData, "");
        }
    }

    private void initSinglePickerView(List<String> data, String title) {
        SinglePickerView singlePickerView = new SinglePickerView(this, title, data) {
            @Override
            public void confirm(String label, int position) {
                if (TextUtils.isEmpty(title)) {
                    if (label.equals(getString(R.string.create_order))) { // 生成订单
                        Bundle bundle = new Bundle();
                        bundle.putString(Constant.idKey, businessId);
                        JumpIntent.jump(BusinessDetailsActivity.this, PlaceOrderActivity.class, bundle);
                    } else if (label.equals(getString(R.string.lost_order))) { // 丢单
                        checkButtonOrTab(7);
                    } else if (label.equals(getString(R.string.discard))) { // 废弃
                        discardBusiness();
                    } else if (label.equals(getString(R.string.discard_examine))) { // 废弃审核
                        discardExamineBusiness();
                    } else {
                        checkButtonOrTab(6); // 设置共享人
                    }
                } else {
                    mTelNumber = label;
                    RequestUtils.checkCallNum(context, mTelNumber, myDialog, 0, true);
                }
            }
        };
        singlePickerView.showSinglePickerView();
    }

    private void initDialog() {
        myDialog = new MyDialog(this) {
            @Override
            public void leftClick() {
                RequestUtils.callNum(context, mTelNumber);
                Constant.pushBusinessId = businessId;
                RequestUtils.addFollow(businessId, clientName, mTelNumber);
            }

            @Override
            public void rightClick() {
                RequestUtils.callbackOutbound(context, mTelNumber, businessId, clientName);
            }
        };
    }

    /**
     * 丢单
     */
    private void releaseBusiness() {
        EditDialog editDialog = new EditDialog(BusinessDetailsActivity.this) {
            @Override
            public void rightClick(String content) {
                JSONObject requestDate = new JSONObject();
                try {
                    requestDate.put("chanceId", businessId);
                    requestDate.put("lostRemark", content);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), requestDate.toString());
                RetrofitHelper.getInstance().execute(RetrofitHelper.getService().lostOrder(requestBody), new MyObserver<HttpRespond<String>>() {
                    @Override
                    protected void onSuccess(HttpRespond<String> stringHttpRespond) {
                        if (stringHttpRespond.code == Constant.SUCCESS) {
                            ToastHelper.show(getString(R.string.lost_order_success));
                            EventBus.getDefault().post(new EventBusModel(Constant.refreshMainBusinessList));
                            BusinessDetailsActivity.this.finish();
                        } else {
                            ToastHelper.show(stringHttpRespond.msg);
                        }

                    }
                });
            }
        };
        editDialog.showDialog();
    }

    /**
     * 废弃
     */
    private void discardBusiness() {
        EditDialog editDialog = new EditDialog(BusinessDetailsActivity.this) {
            @Override
            public void rightClick(String content) {
                Map<String, Object> map = new HashMap<>();
                map.put("attachments", new JsonArray());
                map.put("chanceId", businessId);
                map.put("remark", content);
                map.put("discardType", 0);
                map.put("isDept", 0);
                RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(map));
                RetrofitHelper.getInstance().execute(RetrofitHelper.getService().discardBusiness(requestBody), new MyObserver<HttpRespond<String>>() {
                    @Override
                    protected void onSuccess(HttpRespond<String> stringHttpRespond) {
                        if (stringHttpRespond.code == Constant.SUCCESS) {
                            ToastHelper.show(getString(R.string.discard_success));
                            EventBus.getDefault().post(new EventBusModel(Constant.refreshMainBusinessList));
                            BusinessDetailsActivity.this.finish();
                        } else {
                            ToastHelper.show(stringHttpRespond.msg);
                        }
                    }
                });
            }
        };
        editDialog.setContent(getString(R.string.discard_reason), getString(R.string.input_discard_reason));
        editDialog.showDialog();
    }

    /**
     * 废弃审核
     */
    private void discardExamineBusiness() {
        ExamineDialog examineDialog = new ExamineDialog(BusinessDetailsActivity.this) {
            @Override
            public void rightClick(String content, int result) {
                Map<String, Object> map = new HashMap<>();
                map.put("chanceId", businessId);
                map.put("remark", content);
                map.put("type", result); // 0同意、1拒绝
                RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), new Gson().toJson(map));
                RetrofitHelper.getInstance().execute(RetrofitHelper.getService().checkDiscardBusiness(requestBody), new MyObserver<HttpRespond<String>>() {
                    @Override
                    protected void onSuccess(HttpRespond<String> stringHttpRespond) {
                        if (stringHttpRespond.code == Constant.SUCCESS) {
                            ToastHelper.show(getString(R.string.discard_examine_success));
                            EventBus.getDefault().post(new EventBusModel(Constant.refreshMainBusinessList));
                            BusinessDetailsActivity.this.finish();
                        } else {
                            ToastHelper.show(stringHttpRespond.msg);
                        }
                    }
                });
            }
        };
        examineDialog.showDialog();
    }

    /**
     * 检测是否有按钮权限
     *
     * @param type 1、跟进记录 2、通话记录 3、订单记录 4、添加跟进 5、编辑信息 6、设置共享人 7、丢单 8、商机详情
     */
    private void checkButtonOrTab(int type) {
        JSONObject requestDate = new JSONObject();
        try {
            requestDate.put("type", type);
            // 商机类型  0、我创建的 1、部门创建的 2、我跟进的 3、部门跟进的 4、共享给我的 5、共享给部门的
            if (businessType == 0) {
                requestDate.put("businessType", createUserId.equals(followUserId) ? 2 : businessType);
            } else if (businessType == 1) {
                requestDate.put("businessType", createUserId.equals(followUserId) ? 3 : businessType);
            } else {
                requestDate.put("businessType", businessType);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), requestDate.toString());
        RetrofitHelper.getInstance().execute(RetrofitHelper.getService().checkButtonOrTab(requestBody), new MyObserver<HttpRespond<Boolean>>() {
            @Override
            protected void onSuccess(HttpRespond<Boolean> booleanHttpRespond) {
                if (Constant.SUCCESS == booleanHttpRespond.code) {
                    switch (type) {
                        case 5:
                            if (booleanHttpRespond.data) {
                                Bundle bundle = new Bundle();
                                bundle.putInt(Constant.flagKey, 1);
                                bundle.putString(Constant.businessIdKey, businessId);
                                bundle.putString(Constant.nameKey, detailsModel.getCompName());
                                bundle.putString(Constant.creditNoKey, detailsModel.getCreditNo());
                                JumpIntent.jump(BusinessDetailsActivity.this, EditBusinessActivity.class, bundle);
                            } else {
                                ToastHelper.show(getString(R.string.no_edit_permission));
                            }
                            break;
                        case 6:
                            if (booleanHttpRespond.data) {
                                Bundle bundle = new Bundle();
                                bundle.putString(Constant.businessIdKey, businessId);
                                JumpIntent.jump(BusinessDetailsActivity.this, SetSharePersonActivity.class, bundle);
                            } else {
                                ToastHelper.show(getString(R.string.no_set_share_permission));
                            }
                            break;
                        case 7:
                            if (booleanHttpRespond.data) {
                                releaseBusiness();
                            } else {
                                ToastHelper.show(getString(R.string.no_lost_order_permission));
                            }
                            break;
                    }
                }
            }
        });
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void Event(EventBusModel eventBusModel) {
        if (null != eventBusModel) {
            if (eventBusModel.getMsg().equals(Constant.refreshInformationDetail)) {
                isRefresh = true;
                getBusinessDetails();
            }
            if (eventBusModel.getMsg().equals(Constant.closeOrderDetails)) {
                finish();
            }
        }
    }
}